$(function () {
    $('button').on('tap', function () {
        // var data = $('form ').serialize()
        // console.log(data)
        //
        // var formData = CT.serialize2object(data)
        // console.log(formData)
        var recipients = $.trim($('[name="recipients"]').val())
        var address = $.trim($('[name="address"]').val())
        var postCode = $.trim($('[name="postCode"]').val())
        var addressDetail = $.trim($('[name="addressDetail"]').val())
        // 验证各项是否为空 =
        if (!recipients) {
            mui.toast('请输入姓名！')
            return false
        }
        if (!postCode) {
            mui.toast('请输入邮政编码！')
            return false
        }
        if (!address) {
            mui.toast('请输入省市区！')
            return false
        }
        if (!addressDetail) {
            mui.toast('请输入详细地址！')
            return false
        }
        CT.loginAjax({
            url: '/address/addAddress',
            type: 'post',
            data: {
                address: address,
                addressDetail: addressDetail,
                recipients: recipients,
                postcode: postCode
            },
            dataType: 'json',
            success: function () {
                location.href = 'address.html'
            },
            error: function () {
                mui.toast('网络繁忙！')
            }
        })
    })


})